# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=scribus
pkgver=1.5.8
pkgrel=7
pkgdesc="libre desktop publishing"
url="https://www.scribus.net/"
arch="all"
license="GPL-2.0-or-later"
options="!check" # no test
makedepends="cmake boost-dev cairo-dev cups-dev harfbuzz-dev hunspell-dev
	lcms2-dev libcdr-dev libfreehand-dev libmspub-dev libpagemaker-dev
	libqxp-dev libvisio-dev libzmf-dev mesa-dev poppler-dev qt5-qttools
	qt5-qttools-dev qt5-qtbase-dev python3-dev samurai
	libexecinfo-dev"
subpackages="$pkgname-doc $pkgname-lang"
source="https://downloads.sourceforge.net/scribus/scribus-$pkgver.tar.xz
	fix-util_debug.cpp.patch
	poppler-22.02-1.patch
	poppler-22.02-2.patch
	poppler-22.03.patch
	poppler-22.04.patch
	"

langdir="/usr/share/scribus/translations"
build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DWANT_DISTROBUILD=True \
		-DWANT_CPP17=True \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

sha512sums="
eb46be0165eeb0d8974aa744fc8ffac321b206ca0015da39bb2f50d9fd4a5e28300a49ada0f963b4e0cf9a3301dc746ffba74f359f5e76d308d80b71ee669c2d  scribus-1.5.8.tar.xz
b56359d5e7aa3001cef6a9d6330e5c32a4c7570880b9eeeb79f6ff0ea7a050a5f3964ad0fef653a437e200dfc5d714a8a9c6b30158bbb1abf5d4bc98445f5205  fix-util_debug.cpp.patch
d854a141ddfb66e079bf5f1bf4b8ae6c6c2384838033b423aebbfa78cdc93d649a2979df790b67f1b8ceb6865dfed40a5d42deeb2a7fd3f675b6a5f82d6f5264  poppler-22.02-1.patch
8e91318722006af7ad034bc6f17f331978cd169b6435f148631d2016b03f5207990d4e07fa4ad5ce26dc1c2fcdda8d3aa1689374146da9d181733254f5ca005a  poppler-22.02-2.patch
a441e281555b5ae640e275e130424ffb35975825fa530a40dc051fec6cc0aaa0303f7fb7e6ef767abd4ed661c95aacc8f3dfe7e35e858450a8bf5ce493480175  poppler-22.03.patch
8c13e54b62ea0aebaff9a4f55742159906218bc920c19c9467b975d2e182fe2ea72e71adf29506b9c9a88fb7367365a1bc018d1774f56bb4c4ed6100b97d72d2  poppler-22.04.patch
"
